home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!j-bg.demon.co.uk
- From: John Sargent <jb@j-bg.demon.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Re: main()
- Date: Wed, 17 Apr 96 18:42:21 GMT
- Message-ID: <829766541snz@j-bg.demon.co.uk>
- References: <3174c0dc.7652220@news.flex.com.au>
- Reply-To: jb@j-bg.demon.co.uk
- X-NNTP-Posting-Host: j-bg.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.29
- X-Mail2News-Path: j-bg.demon.co.uk
-
- In article <3174c0dc.7652220@news.flex.com.au>
- cobweb@flex.com.au "Tony L" writes:
-
- > Hi all,
- >
- > I have come across two different ways that 2 different beginners books
- > recommend that every program should start. Could someone please tell
- > me which one is the "BEST" or proper way?
- >
- > #include <stdio.h>
- > void main()
- > {
- > printf("Hello!\n");
- > return 0;
- > }
-
- This is plain wrong. You are trying to return a value ( 0 ) from a function
- that doesn't return a value.
-
-
-
- > Or, the same as above but not include "void":
- >
- > #include <stdio.h>
- > main()
- > {
- > printf("Hello!\n");
- > return 0;
- > }
-
- If you don't specify a return type, the compiler assumes that you mean
- type int.
-
-
- I would use...
-
-
- #include <stdio.h>
- void main(void)
- {
- printf("Hello!\n");
- return;
- }
-
- or
-
- #include <stdio.h>
- int main(void)
- {
- printf("Hello!\n");
- return 0;
- }
-
-
- I personally don't like the parameter list left blank (except in class
- constructors etc.)
-
-
- Regards,
- John Sargent
-